package com.ayg.service;

import com.ayg.mapper.LifeMapper;
import com.ayg.pojo.Life;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class LifeServiceImpl implements LifeService{

    @Autowired
    private LifeMapper lifeMapper;

    @Override
    public void addLifeUpload(Life life) {
        life.setLifeDate(new SimpleDateFormat("yyyy年MM月dd日").format(new Date()));
        life.setStatus(true);
        life.setLifeUrl(life.getLifeUrl());
        lifeMapper.insert(life);
    }

    @Override
    public List<Life> getLifeList() {
        List<Life> lifeList = lifeMapper.selectList(null);
        return lifeList;
    }
}
